<!DOCTYPE html>
<html>
<head>
    <title>税费审核管理</title>
    <#include "../../common/common.ftl"/>
</head>
<body style="overflow-y: hidden;">
<div class="layui-fluid">
    <blockquote class="layui-elem-quote layui-bg-white">
        单据打印【姓名：<span class="jmdf-color-red">${(contract.name)!}</span>】【协议编号：<span
            class="jmdf-color-red">${(contract.contractCode)!}</span>】
    </blockquote>
    <div class="layui-row layui-col-space15 handInMoney">
        <div class="layui-col-lg5 layui-col-md5">
            <div class="layui-card">
                <div class="layui-card-header">
                    税费审核状态：
                <#if contract.deedShStatus == 1><span class="jmdf-color-red">未审核</span></#if>
                <#if contract.deedShStatus == 2><span class="jmdf-color-green">已审核</span></#if>
                <#if contract.deedShStatus == 3><span class="jmdf-color-blue">部分审核</span></#if>
                </div>
                <div class="layui-card-body">
                    <button class="layui-btn layui-btn-fluid setDeedShStatus" style="background-color: <#if contract.deedShStatus == 1>red</#if><#if contract.deedShStatus == 2>green</#if><#if contract.deedShStatus == 3>blue</#if>" contractId="${(contract.id)!}">
                        <#if contract.deedShStatus == 1 || contract.deedShStatus == 3>批全部设置已审核</#if><#if contract.deedShStatus == 2>批全部设置未审核</#if>
                    </button>
                </div>
            </div>
            <form class="layui-form">
                <div class="layui-card">
                    <div class="layui-card-header">
                        <span class="jmdf-color-red">注：若只办理单项税费，可单独设置！！</span>
                    </div>
                    <div class="layui-card-body">
                        <table class="layui-table">
                            <tr>
                                <th style="text-align: center;width: 100px">所在小区</th>
                                <th style="text-align: center;width: 80px">户号</th>
                                <th style="text-align: center;width: 80px">产权人</th>
                                <th style="text-align: center;width: 60px">审核状态</th>
                                <th style="text-align: center;width: 60px">操作</th>
                            </tr>
                        <#if (houseList??)>
                            <#list houseList as house>
                                <tr>
                                    <td style="text-align: center;">${house.azProject.projectName}</td>
                                    <td style="text-align: center;">${house.houseNumStr}</td>
                                    <td style="text-align: center;">
                                        <#assign buyHousePersonHouseList=(buyHousePersonHouseMap[house.id?c])! />
                                        <#if buyHousePersonHouseList?? && buyHousePersonHouseList?size != 0>
                                            <#list buyHousePersonHouseList as buyHousePersonHouse>
                                            ${(buyHousePersonHouse.name)!}<br/>
                                            </#list>
                                        </#if>
                                    </td>
                                    <td>${(deedShMap[house.deedShStatus?c].name)!}</td>
                                    <td style="text-align: center;">
                                        <button class="layui-btn setHouseDeedShStatus" type="button" houseId="${house.id}" deedShStatus="${house.deedShStatus}" style="background-color: <#if house.deedShStatus == 1>red</#if><#if house.deedShStatus == 2>green</#if>" contractId="${(contract.id)!}">
                                            <#if house.deedShStatus == 1>设置已审核</#if><#if house.deedShStatus == 2>设置未审核</#if>
                                        </button>
                                    </td>
                                </tr>
                            </#list>
                        </#if>
                        <#if (carLotList??)>
                            <#list carLotList as carLot>
                                <tr>
                                    <td style="text-align: center;">${carLot.azProject.projectName}</td>
                                    <td style="text-align: center;">${carLot.houseNumStr}</td>
                                    <td style="text-align: center;">
                                        <#assign buyHousePersonCarLotList=(buyHousePersonCarLotMap[carLot.id?c])! />
                                        <#if buyHousePersonCarLotList?? && buyHousePersonCarLotList?size != 0>
                                            <#list buyHousePersonCarLotList as buyHousePersonCarLot>
                                            ${(buyHousePersonCarLot.name)!}<br/>
                                            </#list>
                                        </#if>
                                    </td>
                                    <td>${(deedShMap[carLot.deedShStatus?c].name)!}</td>
                                    <td style="text-align: center;">
                                        <button class="layui-btn layui-btn-fluid setCarLotDeedShStatus" type="button" carLotId="${carLot.id}" deedShStatus="${carLot.deedShStatus}" style="background-color: <#if carLot.deedShStatus == 1>red</#if><#if carLot.deedShStatus == 2>green</#if>" contractId="${(contract.id)!}">
                                            <#if carLot.deedShStatus == 1>设置已审核</#if><#if carLot.deedShStatus == 2>设置未审核</#if>
                                        </button>
                                    </td>
                                </tr>
                            </#list>
                        </#if>
                        <#if (storageRoomList??)>
                            <#list storageRoomList as storageRoom>
                                <tr>
                                    <td style="text-align: center;">${storageRoom.azProject.projectName}</td>
                                    <td style="text-align: center;">${storageRoom.houseNumStr}</td>
                                    <td style="text-align: center;">
                                        <#assign buyHousePersonStorageRoomList=(buyHousePersonStorageRoomMap[storageRoom.id?c])! />
                                        <#if buyHousePersonStorageRoomList?? && buyHousePersonStorageRoomList?size != 0>
                                            <#list buyHousePersonStorageRoomList as buyHousePersonStorageRoom>
                                            ${(buyHousePersonStorageRoom.name)!}<br/>
                                            </#list>
                                        </#if>
                                    </td>
                                    <td>${(deedShMap[storageRoom.deedShStatus?c].name)!}</td>
                                    <td style="text-align: center;">
                                        <button class="layui-btn layui-btn-fluid setStorageRoomDeedShStatus" type="button" storageRoomId="${storageRoom.id}" deedShStatus="${storageRoom.deedShStatus}" style="background-color: <#if storageRoom.deedShStatus == 1>red</#if><#if storageRoom.deedShStatus == 2>green</#if>" contractId="${(contract.id)!}">
                                            <#if storageRoom.deedShStatus == 1>设置已审核</#if><#if storageRoom.deedShStatus == 2>设置未审核</#if>
                                        </button>
                                    </td>
                                </tr>
                            </#list>
                        </#if>
                        </table>
                    </div>
                </div>
            </form>
        </div>
        <div class="layui-col-lg7 layui-col-md7">
            <div class="layui-card">
                <div class="layui-tab layui-tab-brief" id="finance">
                    <ul class="layui-tab-title">

                        <#--<li class="layui-this" source="/pdf/print/deedTaxPrint?contractId=${(contract.id)!}" class="layui-this">契税明细表</li>
                        <li class="printPDF" source="/pdf/print/deedTaxFourPrint?contractId=${(contract.id)!}">契税四方会签表</li>
                        -->
                        <li class="printPDF refreshPDF" source="/pdf/print/deedTaxForTaxDepartmentPrint?contractId=${(contract.id)!}">税务部门</li>
                    </ul>
                    <iframe id="printIframe" style="width: 100%;height: 730px;margin-top: 10px"></iframe>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="/layui/layui.js" charset="utf-8"></script>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(['jquery', 'form', 'layer', 'element', 'jmdf'], function () {
        var $ = layui.jquery, jmdf = layui.jmdf, form = layui.form, layer = layui.layer, element = layui.element;

        //封装打印链接调用方法
        function openPdf(source) {
            var url = source + "#toolbar=0";
            $("#printIframe").attr("src", url);
        }

        //选项卡点击时改变PDF链接
        $(".printPDF").click(function () {
            var source = $(this).attr("source");
            openPdf(source);
        });

        //页面初始化时，默认加载第一个选项卡
        openPdf($("#finance li").attr("source"));


        //选项卡第一个点击时触发
        $(".refreshPDF").click(function () {
            refreshPDF();
        });


        //设置审核状态
        $(".setDeedShStatus").click(function () {
                var msg = '${(contract.deedShStatus)!0}' == 2 ? "未审核" : "已审核";
                layer.open({
                    title: false,
                    shade: 0.5,
                    content: "确认设置为" + msg + "吗？",
                    btn: ['确定', '取消'],
                    closeBtn: 0,
                    btnAlign: 'c'
                    ,
                    yes: function (index) {
                        $.get("setDeedShStatus", {
                            contractId: '${(contract.id)!}',
                            _time: new Date().getTime()
                        }, function (data) {
                            if (data.code == "0001") {//成功
                                layer.msg(data.message, {anim: 0, icon: 1, time: 500}, function () {
                                    location.reload();
                                });
                            } else {//失败
                                layer.msg(data.message, {anim: 6, icon: 2, time: 3000});
                            }
                            layer.close(index);
                        });
                    }
                });
        })

        //设置房屋审核状态
        $(".setHouseDeedShStatus").click(function () {
            var deedShStatus = $(this).attr('deedShStatus');
            var houseId = $(this).attr('houseId');
            var msg = deedShStatus == 2 ? "未审核" : "已审核";
            layer.open({
                title: false,
                shade: 0.5,
                content: "确认设置为" + msg + "吗？",
                btn: ['确定', '取消'],
                closeBtn: 0,
                btnAlign: 'c'
                ,
                yes: function (index) {
                    $.get("setHouseDeedShStatus", {
                        houseId: houseId,
                        _time: new Date().getTime()
                    }, function (data) {
                        if (data.code == "0001") {//成功
                            layer.msg(data.message, {anim: 0, icon: 1, time: 500}, function () {
                                location.reload();
                            });
                        } else {//失败
                            layer.msg(data.message, {anim: 6, icon: 2, time: 3000});
                        }
                        layer.close(index);
                    });
                }
            });
        })

        //设置车位审核状态
        $(".setCarLotDeedShStatus").click(function () {
            var deedShStatus = $(this).attr('deedShStatus');
            var carLotId = $(this).attr('carLotId');
            var msg = deedShStatus == 2 ? "未审核" : "已审核";
            layer.open({
                title: false,
                shade: 0.5,
                content: "确认设置为" + msg + "吗？",
                btn: ['确定', '取消'],
                closeBtn: 0,
                btnAlign: 'c'
                ,
                yes: function (index) {
                    $.get("setCarLotDeedShStatus", {
                        carLotId: carLotId,
                        _time: new Date().getTime()
                    }, function (data) {
                        if (data.code == "0001") {//成功
                            layer.msg(data.message, {anim: 0, icon: 1, time: 500}, function () {
                                location.reload();
                            });
                        } else {//失败
                            layer.msg(data.message, {anim: 6, icon: 2, time: 3000});
                        }
                        layer.close(index);
                    });
                }
            });
        })

        //设置储藏间审核状态
        $(".setStorageRoomDeedShStatus").click(function () {
            var deedShStatus = $(this).attr('deedShStatus');
            var storageRoomId = $(this).attr('storageRoomId');
            var msg = deedShStatus == 2 ? "未审核" : "已审核";
            layer.open({
                title: false,
                shade: 0.5,
                content: "确认设置为" + msg + "吗？",
                btn: ['确定', '取消'],
                closeBtn: 0,
                btnAlign: 'c'
                ,
                yes: function (index) {
                    $.get("setStorageRoomDeedShStatus", {
                        storageRoomId: storageRoomId,
                        _time: new Date().getTime()
                    }, function (data) {
                        if (data.code == "0001") {//成功
                            layer.msg(data.message, {anim: 0, icon: 1, time: 500}, function () {
                                location.reload();
                            });
                        } else {//失败
                            layer.msg(data.message, {anim: 6, icon: 2, time: 3000});
                        }
                        layer.close(index);
                    });
                }
            });
        })

    })
</script>
</html>
